//
//  ContactDetailViewController.m
//  e律师
//
//  Created by 韦淋 on 2017/5/16.
//  Copyright © 2017年 test. All rights reserved.
//

#import "ContactDetailViewController.h"

@interface ContactDetailViewController ()<UIScrollViewDelegate,UITextFieldDelegate>


@property (nonatomic, strong) NSArray *titleArray;
@property (nonatomic, strong) NSArray *imageArray;
@property (nonatomic, strong) NSArray *placeHolderArray;
@property (nonatomic, strong) NSMutableArray *dataSource;
@end

@implementation ContactDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = false;
    self.dataSource = [NSMutableArray array];
    self.view.backgroundColor = [UIColor whiteColor];
    [self initUI];
}
#pragma mark - Private Method
- (void)initUI{
    //    [self.view insertSubview:self.scrollView atIndex:0];
    
    self.barTitleLable.text = @"收费详情";
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    
    scrollView.contentSize = CGSizeMake(0, SCREEN_HEIGHT);
    
    
    scrollView.delegate = self;
    [self.view insertSubview:scrollView atIndex:0];
    
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT * 2)];
    backView.backgroundColor = [UIColor whiteColor];
    [scrollView addSubview:backView];
    
    for (int i = 0; i < self.titleArray.count; i ++) {
        
        
        UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(10, 80 + i * 50, self.view.bounds.size.width - 20, 40)];
        bgView.backgroundColor = [UIColor whiteColor];
        bgView.layer.borderWidth = 1.0f;
        bgView.layer.borderColor = [[UIColor colorWithRed:248.0f/255.0f green:248.0f/255.0f blue:248.0f/255.0f alpha:1.0f] CGColor];
        
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0, 40, 40)];
        view.backgroundColor = [UIColor colorWithRed:248.0f/255.0f green:248.0f/255.0f blue:248.0f/255.0f alpha:1.0f];
        
        UILabel *titleLable = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, 90, 40)];
        titleLable.textColor = [UIColor blackColor];
        titleLable.backgroundColor = [UIColor colorWithRed:248.0f/255.0f green:248.0f/255.0f blue:248.0f/255.0f alpha:1.0f];
        titleLable.font = [UIFont systemFontOfSize:13];
        titleLable.text = self.titleArray[i];
        
        UILabel *redStar = [[UILabel alloc] initWithFrame:CGRectMake(130, 0, 10, 40)];
        redStar.textColor = [UIColor redColor];
        redStar.backgroundColor = [UIColor colorWithRed:248.0f/255.0f green:248.0f/255.0f blue:248.0f/255.0f alpha:1.0f];
        redStar.font = [UIFont systemFontOfSize:13];
        
        [backView addSubview:bgView];
        
        [bgView addSubview:titleLable];
        [bgView addSubview:redStar];
        
        UITextField *inputInfo = [[UITextField alloc] initWithFrame:CGRectMake(160, 80 + i * 50, 200, 40)];
        inputInfo.clearButtonMode = UITextFieldViewModeWhileEditing;
        inputInfo.textAlignment = NSTextAlignmentLeft;
        inputInfo.font = [UIFont systemFontOfSize:13];
        inputInfo.placeholder = self.placeHolderArray[i];
        inputInfo.delegate = self;
        
        UIButton *button_textFiled = [[UIButton alloc] initWithFrame:CGRectMake(160, 80 + i * 50, 200, 40)];
        
        
        
        inputInfo.tag = i + 100;
        button_textFiled.tag = i + 100;
        
        inputInfo.userInteractionEnabled = NO;
        button_textFiled.hidden = YES;
        
        //        [inputInfo addTarget:self action:@selector(textFieldsDidClick:) forControlEvents:(UIControlEventTouchDown)];
        
        UIImageView *titleImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 20, 20)];
        titleImage.backgroundColor = [UIColor colorWithRed:248.0f/255.0f green:248.0f/255.0f blue:248.0f/255.0f alpha:1.0f];
        titleImage.image = [UIImage imageNamed:self.imageArray[i]];
        
        if (i == self.titleArray.count - 1) {
            UIButton *callButton = [UIButton buttonWithType:UIButtonTypeCustom];
            callButton.frame = CGRectMake(20, 80 + (i + 1) * 50 + 130, self.view.bounds.size.width - 40, 40);
            [callButton setTitle:@"拨号" forState:UIControlStateNormal];
            callButton.titleLabel.textColor = [UIColor whiteColor];
            callButton.layer.cornerRadius = 5;
            callButton.layer.masksToBounds = YES;
            callButton.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
            [callButton addTarget:self action:@selector(action_Call) forControlEvents:UIControlEventTouchUpInside];
            
            UIButton *textButton = [UIButton buttonWithType:UIButtonTypeCustom];
            textButton.frame = CGRectMake(20, 80 + (i + 2) * 50 + 130, self.view.bounds.size.width - 40, 40);
            [textButton setTitle:@"发短信" forState:UIControlStateNormal];
            textButton.titleLabel.textColor = [UIColor whiteColor];
            textButton.layer.cornerRadius = 5;
            textButton.layer.masksToBounds = YES;
            textButton.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
            [textButton addTarget:self action:@selector(action_Text) forControlEvents:UIControlEventTouchUpInside];
            
            [backView addSubview:callButton];
            [backView addSubview:textButton];
        }
        [bgView addSubview:titleImage];
        [backView addSubview:inputInfo];
        [backView addSubview:button_textFiled];
        [bgView insertSubview:view belowSubview:titleImage];
    }
    
    
    
}
- (void)action_Call{
    
}
- (void)action_Text{
    
}

//- (void)action_ClickButton:(UIButton *)sender{
//
//    NSLog(@"tag = %ld",sender.tag);
//}

-(void)showMyMessage:(NSString*)aInfo {
    
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:aInfo delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    
    [alertView show];
    
}
- (NSArray *)titleArray{
    if (!_titleArray) {
        
        _titleArray = [NSArray arrayWithObjects:@"姓名：",@"手机：",@"所属机构：",@"传真：",@"邮箱：",@"家庭住址：",nil];
        
    }
    return _titleArray;
}

- (NSArray *)placeHolderArray{
    if (!_placeHolderArray) {
        
        _placeHolderArray = [NSArray arrayWithObjects:@"无",@"无",@"无",@"无",@"无",@"无",nil];
    }
    return _placeHolderArray;
}
- (NSArray *)imageArray{
    if (!_imageArray) {
        
        _imageArray = [NSArray arrayWithObjects:@"llist_01",@"llist_02",@"llist_03",@"llist_0",@"llist_05",@"llist_05",nil];
    }
    return _imageArray;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
